#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    initScene();
    //打开游戏窗口
    connect(ui->startButton,&QPushButton::clicked,[=]()
    {
        game_view=new GameWindow;
        game_view->show();
    });
    //打开规则窗口
    rule_view=new rule;
    ui->stackedWidget->addWidget(rule_view);
    connect(ui->ruleButton,&QPushButton::clicked,[=](){
        ui->stackedWidget->setCurrentWidget(rule_view);
    });
//    connect(rule_view,&rule::closeWindow,[=](){
//        ui->stackedWidget->setCurrentWidget(ui->page);
//    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::initScene()
{
    setFixedSize(MAIN_WIDTH,MAIN_HEIGHT);
    setWindowTitle(GAME_TITLE);
    setWindowIcon(QIcon(":/picture/images/me1.png"));
}


void MainWindow::on_backButton_clicked()
{
    close();
}
